home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 299_01 / mel.doc < prev    next >
Text File  |  1989-12-28  |  8KB  |  164 lines

  1.                  MEL - a Universal Metalanguage Data Processor
  2.  
  3. MEL provides an I/O interface between a program and the user.  It can take 
  4. input data written in "pseudo-English" and translate it into program 
  5. variables.  It can also take your program's variables and translate it into 
  6. pseudo-English.  You may find the MEL interface useful in developing your own 
  7. programs because: 1) the pseudo-English look of MEL means that I/O will be 
  8. more readable and comprehensible to the user, 2) MEL is "object oriented" in 
  9. that it provides a structured and encapsulated I/O interface, 3) MEL output 
  10. from one program can serve as MEL input to another, and 4) MEL can read and 
  11. write directly to a file so that a permanent record of a run and its results 
  12. are available.
  13.  
  14. MEL originated for use with engineering analysis programs.  It was written in 
  15. ANSI C, and was developed on an IBM PC using Microsoft C, Version 5.1. 
  16.  
  17. A unit of pseudo-English I/O in MEL is called a "descriptor."  Its purpose is 
  18. to describe something, either data or a command, to a program.  The general 
  19. format for descriptors is much like function calls in typical programming 
  20. languages.  An I/O unit consists of a descriptor name (somewhat like 
  21. a function name), followed by a parameter list, followed by an end-of-unit 
  22. symbol (the semicolon).  For example, consider the following MEL descriptor: 
  23.  
  24.         pipe, length = 100 (ft), diameter = 6 (in);
  25.  
  26. This is a "pipe" descriptor whose parameters are "length" and "diameter".  
  27. The values taken by these parameters are as shown, and in the units specified.  
  28. An unusual feature of MEL is that, unlike most programming languages, MEL's 
  29. parameter list is strongly "free-format".  (See List of Features below.) 
  30.  
  31. In order to incorporate MEL into one of your programs you must first create a 
  32. "dictionary" for both input and output that defines the proper spelling, 
  33. number, and types (integer, array, etc.) of data associated with each 
  34. descriptor and parameter.  This is done by customizing the mel.h header file 
  35. which you then include in your application source code file.  mel.h contains 
  36. information and an example of just how this is done.
  37.  
  38. LIST OF MEL FEATURES:
  39.  
  40. 1.  I/O units, called descriptors, are separated by semicolons and thus may 
  41. extend more than one line.  For example:
  42.  
  43.         pipe,                           "first descriptor"
  44.             length = 100 (ft),
  45.             diameter = 6 (in);
  46.         elbow,                          "another descriptor"
  47.             radius = 9 (in);
  48.  
  49. 2.  Comments are any characters enclosed in "quotes."  They may appear 
  50. anywhere in the I/O stream and can contain any amount of whitespace (tabs, 
  51. line-feeds, spaces, etc.).  For example:
  52.  
  53.         pipe, length "this comment 
  54.                                    is ignored" = 100 (ft);
  55.  
  56. 3.  A descriptor's name and its parameters are separated by commas.
  57.  
  58. 4.  Whitespace is generally ignored by MEL and cannot serve as a delimiter. 
  59. An exception is for spaces within array and string data (see 9. below).  For 
  60. example, the following are equivalent: 
  61.  
  62.         pipe, type = 'steel';
  63.         p i p e, t y p e = 'steel' ;  "note that no spaces are allowed
  64.                                        within single quotes (strings). "
  65.  
  66. 5.  Descriptor and parameter names may be abbreviated (shortened) as long as 
  67. they can remain unambiguously identifiable to MEL.  For example, if the input 
  68. dictionary has only one descriptor type that starts with the letter "p", which 
  69. itself has only one parameter starting with the letter "t", then the following 
  70. are equivalent: 
  71.  
  72.         pipe, type = 'steel';
  73.         p, t = steel;          "if no blanks, single-quotes are optional"
  74.  
  75. 6.  Usually, defining a parameter value consists of giving a parameter name, 
  76. an equals sign, a value, and units in parentheses.  However, there are lots 
  77. of exceptions since MEL allows as much flexibility as possible (see the
  78. following). 
  79.  
  80. 7.  If a descriptor has only one parameter associated with it, the 
  81. parameter's name may be omitted.  For example: 
  82.  
  83.         title, 'note that strings containing spaces must be enclosed in 
  84. single quotes. (for long strings note that line-feeds, or any other 
  85. whitespace besides blanks, will be purged.)'; 
  86.  
  87.  
  88. 8.  Additionally, if more than one parameter name is missing, a default order 
  89. is assumed.  (They are assumed to be in the same order as defined in the 
  90. dictionary created by the program developer using MEL.)  For example, if a 
  91. "branch" descriptor's parameters are defined in the order: "number", 
  92. "from_node", and "to_node", then the following would be equivalent: 
  93.  
  94.         branch, number = 100, from_node = 1, to_node = 2;
  95.         branch, 100, 1, 2;
  96.         branch, to_node = 2, from_node = 1, number = 100;
  97.             "user may override default order."
  98.  
  99.  
  100. 9.  Parameter array values are enclosed in {brackets} and separated by at 
  101. least one blank.  For example: 
  102.  
  103.         fluid, temperature = {100 200 300 400 500} (F), 
  104.                viscosity   = {1.0 0.8 0.5 0.1 .05} (cp);
  105.  
  106.  
  107. 10. If a parameter's value is not known, it may be given the value "unknown".  
  108. For example: 
  109.  
  110.         node, pressure = unknown;
  111.  
  112. 11. If a parameter can only be either "true" or "false", giving its name sets 
  113. it equal to true.  For example, the following are equivalent: 
  114.                                        
  115.         analyze, newton_method = true; 
  116.         analyze, newton_method;        
  117.                                          
  118. 12. Units for parameter values must be enclosed in parentheses.  It is up to 
  119. the program using MEL to make any required units conversion to units the 
  120. program may be using internally.  (Such a program is included with the MEL 
  121. diskette.)  The following is an example of attaching units to parameter values 
  122. (where pipe length is in feet, and pipe diameter is in inches): 
  123.  
  124.         pipe, length = 100 (ft), diameter = 6 (in);
  125.  
  126. 13. MEL is case sensitive.  The following are NOT equivalent:
  127.  
  128.         pipe, length = 100 (ft), diameter = 6 (in);
  129.         Pipe, Length = 100 (ft), Diameter = 6 (in);
  130.  
  131.  
  132. STEPS FOR USING MEL FOR PROGRAM I/O:
  133.  
  134. 1.  Compose input and output data tokens.  For example, consider the following 
  135. example that does nothing other than (fancily) passes a message from input to 
  136. output: 
  137.  
  138.         program_data,                     "input and output identical.   "
  139.                 program = 'sss',          "note: 'sss' is a string.      "
  140.                 date = 'sss',             "      nnn stands for a number."
  141.                 input_filename = 'sss',
  142.                 output_filename = 'sss',
  143.                 errors_filename = 'sss',
  144.                 label = 'sss';
  145.         program_options,
  146.                 output_format = 'sss';
  147.         message,
  148.                 code = nnn,
  149.                 text = 'sss';
  150.         end_of_data;
  151.  
  152. 2.  Modify file mel.h to define dictionaries for composed descriptors.  (The 
  153. file has been initialized for the above example already.)  Instructions on how 
  154. to modify the file are contained within the file itself.  Recompile the mel.c 
  155. file.
  156.  
  157. 3.  Using file mel_test.c as a guide, write functions that translate 
  158. descriptors into (from) program data and variables.  (mel_test.c has been 
  159. initialized for the above example already.)  Compile your application source 
  160. code file.
  161.  
  162. 4.  Link your application program with the mel.obj file.
  163.  
  164.